// StereoMaker
// Copyright(C) 2012 Vadim Trochinsky
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.


#ifndef _STEREO_H
#define _STEREO_H

#include <inttypes.h>
#include <stdbool.h>

#include <FreeImage.h>


#define STEREO_LEFT	0
#define STEREO_RIGHT	1
#define STEREO_COMBINED	2


#define STEREO_ANAGLYPH 		0x01
#define STEREO_HORIZONTAL_INTERLACED	0x02
#define STEREO_VERTICAL_INTERLACED	0x04
#define STEREO_CROSS_EYED		0x08
#define STEREO_FLIP			0x10
#define STEREO_CHECKERBOARD		0x20

#define STEREO_FMT_JPEG			FIF_JPEG
#define STEREO_FMT_PNG			FIF_PNG

#define STEREO_OK			0
#define STEREO_ERROR			1
#define STEREO_FILES_MISSING		2
#define STEREO_SIZE_MISMATCH		3

typedef struct {
	char *left_file;       /** Left file */
	char *right_file;      /** Right file */
	char *combined_file;   /** File containing both sides */

	int middle_cutoff  ;   /** In combined_file, the number of pixels to ignore in the middle of the image. Used for camera beam splitters */

        FIBITMAP *img_left;    /** Left bitmap */
        FIBITMAP *img_right;   /** Right bitmap */
        FIBITMAP *img_result;  /** Resulting bitmap */
} StereoGenerator;


StereoGenerator* StereoAlloc();

void StereoFree(StereoGenerator *stereo);

void StereoSetFile(StereoGenerator *stereo, int side, const char *file);

void StereoSetMiddleCutoff(StereoGenerator *stereo, int num_pixels);

int StereoCompute(StereoGenerator *stereo, int type);

int StereoWriteOutput(StereoGenerator *stereo, const char *output, int format);

void StereoDestroy(StereoGenerator *stereo);


#endif
